//
//  GHHomeController.m
//  12-guhu_weibo
//
//  Created by GHapple on 15-1-31.
//  Copyright (c) 2015年 itcast. All rights reserved.
//

#import "GHHomeController.h"
#import "GHScanViewController.h"
#import "GHtitleBtn.h"
#import "GHtestTableViewController.h"
#import "GHPopMenuView.h"

@interface GHHomeController ()

@end

@implementation GHHomeController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.defaultView.iconName = @"visitordiscover_feed_image_house";
    self.defaultView.lablestring = @"当你关注一些人以后，他们发布的最新消息会显示在这里";
    
    [self setNav];
}



- (void)viewWillAppear:(BOOL)animated{
    
    [self.defaultView startTurn];
}

- (void)viewWillDisappear:(BOOL)animated{
    [self.defaultView stopTurn];
}
/**
 *  设置导航栏
 */
- (void)setNav{


    self.navigationItem.leftBarButtonItem  = [UIBarButtonItem itemWithImage:@"navigationbar_friendsearch"  higImage:@"navigationbar_friendsearch_highlighted" target:self action:@selector(friendsSearch)];
    
    self.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithImage: @"navigationbar_pop"higImage:@"navigationbar_pop_highlighted" target:self action:@selector(scan)];
    GHtitleBtn *titleBtn = [[GHtitleBtn alloc]init];
    [titleBtn setTitle:@"首页" forState:UIControlStateNormal];
    // 设置默认的图片
    [titleBtn setImage:[UIImage imageNamed:@"navigationbar_arrow_down"] forState:UIControlStateNormal];
    [titleBtn setImage:[UIImage imageNamed:@"navigationbar_arrow_up"] forState:UIControlStateSelected];
    
    [titleBtn sizeToFit];
    // 监听按钮的点击
    [titleBtn addTarget:self action:@selector(titleBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    
    self.navigationItem.titleView = titleBtn;



}
- (void)titleBtnClick:(GHtitleBtn *)btn{
// 切换按钮的状态
    btn.selected = !btn.selected;
    GHtestTableViewController *vc = [[GHtestTableViewController alloc]init];
    vc.view.size = CGSizeMake(150, 200);
  [GHPopMenuView popFrom:btn contentVC:vc dismiss:^{
      btn.selected = !btn.selected;
  }];
    
    

}
- (void)friendsSearch{
    
    
}

- (void)scan{

    UIStoryboard *sb = [UIStoryboard storyboardWithName:@"GHScanView" bundle:nil];
    UIViewController *scanVc = [sb  instantiateInitialViewController];
    [self presentViewController:scanVc animated:YES completion:nil];

    
}
@end
